<template>
    <div class="institutionsLess">
        <div class="toSignUp-box">
            <span class="t-a-l span-bm">机构信息</span>
            <div v-if="JSON.stringify(formLabelAlign) != '{}'">
                <el-row :gutter="20">
                    <el-col :span="16" :offset="1">
                        <div class="grid-content bg-purple" v-if="formLabelAlign.auditStatus == 2">
                            机构许可证号：{{formLabelAlign.license}}
                        </div>
                    </el-col>
                </el-row>
                <el-form label-position="left" label-width="120px" :model="formLabelAlign">
                    <el-row :gutter="20">
                        <el-col :span="10" :offset="1">
                            <div class="grid-content bg-purple">
                                <el-form-item label="公司全称">
                                    <el-input v-model="formLabelAlign.companyName" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                               <el-form-item label="联系人">
                                    <el-input v-model="formLabelAlign.user.name" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10" :offset="1">
                            <div class="grid-content bg-purple">
                                <el-form-item label="税务编号">
                                    <el-input v-model="formLabelAlign.taxNumber" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                               <el-form-item label="联系人手机号">
                                    <el-input v-model="formLabelAlign.user.phone" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10" :offset="1">
                            <div class="grid-content bg-purple">
                                <el-form-item label="企业类型">
                                    <el-select v-model="formLabelAlign.companyCategory" placeholder="请选择" :disabled="isdisabled">
                                        <el-option v-for="item in corporationTypeArr" :key="item" :label="item" :value="item"></el-option>
                                    </el-select>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                               <el-form-item label="开户银行名">
                                    <el-input v-model="formLabelAlign.bankName" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10" :offset="1">
                            <div class="grid-content bg-purple">
                                <el-form-item label="纳税人识别号">
                                    <el-input v-model="formLabelAlign.taxpayerNumber" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                               <el-form-item label="开户银行账号">
                                    <el-input v-model="formLabelAlign.bankAccount" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10" :offset="1">
                            <div class="grid-content bg-purple">
                                <el-form-item label="公司地址">
                                    <el-input v-model="formLabelAlign.companyAddress" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                               <el-form-item label="固定电话">
                                    <el-input v-model="formLabelAlign.user.telephone" :disabled="isdisabled"></el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10" :offset="1">
                            <div class="grid-content bg-purple">
                               <el-form-item label="状态">
                                    {{formLabelAlign.auditStatus | auditStatusFiler}}
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :span="10" v-if="formLabelAlign.auditStatus == 3">
                            <div class="grid-content bg-purple">
                               <el-form-item label="驳回原因" class="bh-red">
                                    {{formLabelAlign.rejectReason}}
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
        </div>
        <el-button v-if="isdisabled" class="go-pay" @click="isdisabled = false">编辑</el-button>
        <el-button v-if="isdisabled == false" class="go-pay" @click="isdisabled = true,orgSubmit()">保存</el-button>
        <el-button v-if="formLabelAlign.auditStatus==0 || formLabelAlign.auditStatus==3" class="go-pay" @click="orgSubmitSh">提交审核</el-button>
    </div>
</template>
<script>
import apiHttp from '../../../api/index.js'
export default {
    data(){
        return{
            formLabelAlign:{},
            corporationTypeArr:['国企','外企','民企','国家机关','事业单位','社会团体','个体','其他'],
            isdisabled:true
        }
    },
    mounted(){
        this.detail()
    },
    filters:{
        auditStatusFiler(val){
            if(val == 0){
                return '待提交'
            }else if(val == 1){
                return '待审核' 
            }else if(val == 2){
                return '已通过'
            }else{
                return '已驳回'
            }
        }
    },
    methods:{
        goPay(){
            this.$router.push({
                path:'/students/myTest'
            })
        },
        detail(){
            apiHttp.apiIndex.orgdetail().then(resp=>{
                if(resp.code == 0){
                    if(resp.data){
                        this.formLabelAlign = resp.data
                    }
                }
            })
        },
        orgSubmit(){
            apiHttp.apiIndex.orgupdate(this.formLabelAlign).then(resp=>{
                if(resp.code == 0){
                    this.$message({
                        type: 'success',
                        message: '保存成功!'
                    })
                }
            })
        },
        orgSubmitSh(){
            apiHttp.apiIndex.orgApplyAudit('').then(resp=>{
                if(resp.code == 0){
                    this.$message({
                        type: 'success',
                        message: '提交审核成功，请耐心等待!'
                    })
                    this.detail()
                }else{
                    this.$message.error(resp.message)
                }
            })
        },
    }
}
</script>

<style lang="less">
.institutionsLess{
    .toSignUp-box{
        border: solid 1px #bfbfbf;
        border-radius: 5px;
        padding: 20px;
        width: 85%;
        margin: 0 auto;
        .grid-content{
            text-align: left;
            height: 50px;
            line-height: 50px;
            .el-input{
                width: 200px;
            }
        }
    }
    .bh-red{
        .el-form-item__label,.el-form-item__content{
            color: red;
        }
    }
    .go-pay{
        margin-top: 30px;
        background-color: #5d2805;
        color: #fff;
        border-color: #5d2805;
        cursor: pointer;
        font-size: 16px;
    }
}
</style>

